home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Sound / AHI / Developer / examples / Extras / CheckAHIPrefs / CheckAHIPrefs.c < prev    next >
C/C++ Source or Header  |  1997-11-02  |  2KB  |  83 lines

  1.  
  2. /* Just a small example how to read the settings file. */
  3.  
  4. #include <devices/ahi.h>
  5. #include <dos/dos.h>
  6. #include <libraries/iffparse.h>
  7. #include <prefs/prefhdr.h>
  8.  
  9. #include <proto/dos.h>
  10. #include <proto/iffparse.h>
  11.  
  12. int main(int argc, char *argv[])
  13. {
  14.   struct IFFHandle *iff;
  15.   struct StoredProperty *ahig;
  16.   struct CollectionItem *ci;
  17.   LONG unit = 0;
  18.   int rc = RETURN_OK;
  19.  
  20.   if(argc != 3) {
  21.     Printf("Usage: %s FILE UNIT\n", argv[0]);
  22.     return RETURN_FAIL;
  23.   }
  24.  
  25.   StrToLong(argv[2], &unit);
  26.  
  27.   if(iff = AllocIFF())
  28.   {
  29.     iff->iff_Stream = Open(argv[1], MODE_OLDFILE);
  30.     if(iff->iff_Stream)
  31.     {
  32.       InitIFFasDOS(iff);
  33.       if(!OpenIFF(iff, IFFF_READ))
  34.       {
  35.         if(!(PropChunk(iff,ID_PREF,ID_AHIG)
  36.           || CollectionChunk(iff,ID_PREF,ID_AHIU)
  37.           || StopOnExit(iff,ID_PREF,ID_FORM)))
  38.         {
  39.           if(ParseIFF(iff, IFFPARSE_SCAN) == IFFERR_EOC)
  40.           {
  41.  
  42.             ahig = FindProp(iff,ID_PREF,ID_AHIG);
  43.             if(ahig)
  44.             {
  45.               struct AHIGlobalPrefs *globalprefs;
  46.               globalprefs = (struct AHIGlobalPrefs *)ahig->sp_Data;
  47.  
  48.               if(globalprefs->ahigp_DebugLevel != AHI_DEBUG_NONE)
  49.               {
  50.                 Printf("Debugging is turned on.*n");
  51.                 rc = RETURN_WARN;
  52.               }
  53.             }
  54.  
  55.             ci = FindCollection(iff,ID_PREF,ID_AHIU);
  56.             while(ci)
  57.             {
  58.               struct AHIUnitPrefs *unitprefs;
  59.               unitprefs = (struct AHIUnitPrefs *)ci->ci_Data;
  60.  
  61.               if(unitprefs->ahiup_Unit == unit)
  62.               {
  63.                 if(unitprefs->ahiup_Channels < 2)
  64.                 {
  65.                   Printf("There is less than 2 channels selected for unit %ld.*n", unit);
  66.                   rc = RETURN_WARN;
  67.                 }
  68.               }
  69.               ci=ci->ci_Next;
  70.             }
  71.  
  72.           }
  73.         }
  74.         CloseIFF(iff);
  75.       }
  76.       Close(iff->iff_Stream);
  77.     }
  78.     FreeIFF(iff);
  79.   }
  80.  
  81.   return rc;
  82. }
  83.